#include<iostream>
#include<stack>
using namespace std;

const int N = 1e6 + 10;
unsigned long long stk[N];
unsigned long long x;
int top, n, T;

int main()
{
    cin >> T;
    while(T--)
    {
        cin >> n;
        top = 0;
        while(n--)
        {
            string op;
            cin >> op;
            if(op == "push")
            {
                cin >> x;
                stk[++top] = x;
            }
            else if(op == "pop")
            {
                if(top == 0) cout << "Empty" << endl;
                else top--;
            }
            else if(op == "query")
            {
                if(top == 0) cout << "Anguei!" << endl;
                else cout << stk[top] << endl;
            }
            else if(op == "size")
            {
                cout << top << endl;
            }
        }
    }
    return 0;
}